package com.leetcode.LC;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class LC1403 {
    public List<Integer> minSubsequence(int[] nums) {
        List<Integer> list = new ArrayList<Integer>();
        int count = 0, current = 0;
        Arrays.sort(nums);
        for (int num : nums)
            count += num;
        for (int i = nums.length - 1; i >= 0; i--) {
            list.add(nums[i]);
            if ((current += nums[i]) - (count -= nums[i]) > 0)
                break;
        }
        return list;
    }
}
